package cn.stylefeng.guns.modular.business.custom.convert;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @Description:
 * @Author jzy
 * @Date 2021/9/15 0015
 **/
public class CompanyTypeConvert implements Converter<Integer> {
    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.NUMBER;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if ("企业".equals(cellData.getStringValue())) {
            return 1;
        } else if ("同行".equals(cellData.getStringValue())) {
            return 2;
        } else if ("个人".equals(cellData.getStringValue())) {
            return 3;
        }
        return 0;
    }

    @Override
    public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (integer == 1) {
            return new CellData("企业");
        } else if (integer == 2) {
            return new CellData("同行");
        } else if (integer == 3) {
            return new CellData("个人");
        }
        return new CellData("-");
    }
}
